<template>
  <div>
    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">
        <template slot="serialNum" slot-scope="text,record,index">
          {{(ipagination.current-1) * ipagination.pageSize + parseInt(index) + 1}}
        </template>
        <span slot="action" slot-scope="text, record">
          <a @click="handleDetail(record)">{{$t('m.common.title.detail')}}</a>
        </span>

      </a-table>
    </div>

    <delegate-modal ref="modalForm" @ok="modalFormOk"></delegate-modal>

  </div>
</template>

<script>

  import {YcListMixin} from '@/mixins/YcListMixin';
  import DelegateModal from "./DelegateModal";
  import YchConstant from "@/api/YchConstant";
  import LocaleUtil from "../../../../utils/LocaleUtil";

  export default {
    name: "QueryDelegateTask",
    mixins: [YcListMixin],
    components: {
      DelegateModal
    },
    data() {
      return {
        // 表头
        columns: [
          {
            title:this.$t('m.common.label.number'),
            dataIndex: '',
            key: 'rowIndex',
            width: 50,
            align: "center",
            scopedSlots: { customRender: 'serialNum' },
          },
          {
            title: this.$t('m.bpm.entity.delegateBailee'),
            align: "center",
            dataIndex: 'userName',
            width: 180,
            customRender: function (t, r, index) {
              return t + (r.deptName ? '/' + r.deptName : '');
            }
          },
          {
            title: this.$t('m.bpm.entity.delegateResource'),
            align: "center",
            dataIndex: 'resourceAll',
            width: 130,
            customRender: function (t, r, index) {
              if (t) {
                return LocaleUtil.getLocale('m.common.label.all');
              } else {
                return LocaleUtil.getLocale('m.common.label.part');
              }
            }
          },
          {
            title: this.$t('m.bpm.entity.startTimeString'),
            align: "center",
            dataIndex: 'startTimeString',
            width: 130
          },
          {
            title: this.$t('m.bpm.entity.endTimeString'),
            align: "center",
            dataIndex: 'endTimeString',
            width: 130
          },
          {
            title: this.$t('m.common.label.status'),
            align: "center",
            dataIndex: 'statusString',
            width: 80
          },
          {
            title: this.$t('m.common.label.operate'),
            dataIndex: 'action',
            align: "center",
            scopedSlots: {customRender: 'action'},
            width: 120
          }
        ],
        url: {
          list: YchConstant.PREFIX_BPM + "/bpm-front/delegateTaskRest/listMyAcceptDelegateSetting/v1"
        }
      }
    },
    methods: {
      handleDetail: function (record) {
        this.$refs.modalForm.edit(record);
        this.$refs.modalForm.title = this.$t('m.common.title.detail');
        this.$refs.modalForm.disabled = true;
      }
    }
  }
</script>
<style lang="less" scoped>

</style>
